﻿-- =============================================
-- Author:		<赵洪涛>
-- Create date: <2011-12-09>
-- Description:	<根据助记词搜索客户（非自己，修改时用）>
-- =============================================
CREATE PROCEDURE [dbo].[proc_Customer_SearchMnemonicWorks_NOME] 
		@MnemonicWorks nvarchar(50),
		@UserName nvarchar(50),
		@CustomerId uniqueidentifier
AS
BEGIN
	DECLARE @CompanyId int
	Select @CompanyId=CompanyId From Employee Where UserName=@UserName
	
	Select top 20
	Id,
	CustomerId,
	CustomerName,
	MnemonicWorks,
	Tel,
	(Select Title From Customer_Protect Where Id=Customer.ProtectId) As Protect,
	(Select EName From Employee Where UserName=Customer.CreateName) As CreateNameEName,
	CreateDate 
--	From Customer Where CompanyId=@CompanyId And CustomerName like '%'+ @MnemonicWorks +'%' And CustomerId<>@CustomerId
	From Customer Where CompanyId=@CompanyId And ((CustomerName like '%'+@MnemonicWorks+'%' And @MnemonicWorks<>'') Or MnemonicWorks=@MnemonicWorks) And CustomerId<>@CustomerId
END

